package com.bto.solar.work.controller;

import com.bto.solar.work.common.R;
import com.bto.solar.work.entity.Area;
import com.bto.solar.work.service.BtoCompanyService;
import com.bto.solar.work.vo.CompanyVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 中国地区表 前端控制器
 * </p>
 *
 * @author adrian
 * @since 2023-08-09
 */
@RestController
@RequestMapping("/area")
public class AreaController {

    @Autowired
    private BtoCompanyService btoCompanyService;

    @GetMapping()
    public R<List<CompanyVO.AreaVO>> index()  {
        return R.ok(btoCompanyService.getAreaInfos());
    }

    @GetMapping("/id")
    public R<List<Area>> getAreaById(@RequestParam(value = "id", required = false) Long id)  {
        return R.ok(btoCompanyService.getAreaInfos(id));
    }

}
